<!DOCTYPE html>
<html lang="en">

<head>
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <link rel="stylesheet" href="/js/bootstrap-4.1.1-dist/css/bootstrap.min.css">
    <script src="/js/jquery/jquery.min.js"></script>
    <script src="/js/bootstrap-4.1.1-dist/js/bootstrap.min.js"></script>
    <script src="/js/plugins/jrender/jrender.min.js"></script>
    <link rel="stylesheet" href="/css/font/css/font-awesome.min.css"/>
    <link rel="stylesheet" href="/css/reset.css"/>
    <link rel="stylesheet" href="/css/userTravels.css"/>
    <link rel="stylesheet" href="/js/plugins/dialog2/dialog.css"/>
    <script src="/js/plugins/dialog2/dialog.min.js"></script>
    <script src="/js/common.js"></script>
    <script src="/js/checkLogin.js"></script>


    <meta charset="utf-8">
    <meta content="email=no" name="format-detection">
    <meta content="telephone=no" name="format-detection">
    <meta name="msapplication-tap-highlight" content="no">
    <meta content="yes" name="apple-mobile-web-app-capable">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta content="black" name="apple-mobile-web-app-status-bar-style">
    <meta content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no" name="viewport">
    <!--<link rel="shortcut icon" href="http://www.tyfo.com/market/content/home_image/favicon.ico" type="image/x-icon"/>-->
    <title>转盘抽奖</title>
    <style>
        p,
        body {
            margin: 0;
        }

        .rui-luck-draw {
            width: 100vw;
            height: 100vh;
            position: fixed;
            top: 0;
            left: 0;
        }

        .rui-luck-content {
            height: 75vw;
            width: 75vw;
            max-width: 550px;
            max-height: 550px
        }

        .rui-luck-turntable,
        .rui-luck-pointer {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%) rotate(0deg);
            transform-origin: center center;
            -webkit-transform-origin: center center;
            -moz-transform-origin: center center;
            -ms-transform-origin: center center;
            -o-transform-origin: center center;
        }

        .rui-luck-name {
            font-size: 16px;
            text-align: left;
            height: 30px;
            line-height: 30px;
            position: fixed;
            top: 0;
            left: 0;
            z-index: 100;
        }

        .rui-luck-name a {
            text-decoration: none;
            color: #777;
            padding: 0 20px;
        }

        .rui-luck-pointer {
            width: 27vw;
            height: 27vw;
            max-width: 205px;
            max-height: 205px
        }
    </style>

</head>

<body background="/mine/lotto/images/bg.png">

<div class="rui-luck-draw">

    <div class="search-head">
        <div class="row nav-search">
            <div class="col">
                <a href="/mine/signIn.html">
                    <span><i class="fa fa-chevron-left"></i></span>
                </a>
            </div>
            <div class="col">
                <span>我的抽奖</span>
            </div>
            <div class="col"></div>
        </div>

    </div>
    <br>
    <div id="lotto1">
        <button id="jifen">剩余积分:</button>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <a render-key="id" render-fun="getHref"  data-url="/mine/lottoHistory.html?userId="  style="color: deeppink;text-decoration:underline;">点击查看中奖历史</a>
        <div class="rui-luck-content">
            <div class="rui-luck-box">
                <img id="luckTurntable" src="./images/turntable.png" alt="" class="rui-luck-content rui-luck-turntable">
                <img id="luckPointer"  src="./images/pointer.png" class="rui-luck-pointer"/><!--onclick="startRotate(this)"-->
            </div>
        </div>
    </div>
</div>
<script src="./luckDraw.js"></script>
<script>
    // 转盘旋转，从左向右逆时针计算奖品
    var luckArr = ['java基础班', '华为P30Pro', '马尔代夫一日游', '一毛安慰奖', '棒棒糖', '美胸保养'];
    var luck = new LuckDraw();
    var startRotate = function (elem) {
        luck._init({
            rotateId: '#luckTurntable',
            luckNumber: Math.floor(Math.random() * (6 - 0) + 0),
            typeNumber: 6,
            time: 2000,
            type: 'turntable',
            circleNumber: 10,
            success: function (res) {
                mark=luckArr[res.luckNumber];
                console.log(res.luckNumber);
                console.log(luckArr[res.luckNumber]);
                $(document).dialog({
                    titleText: '抽奖结果',
                    content: mark

                });
                $.post(baseUrl+"/lottoHistorys",{userId:userId,mark:mark},function (data) {

                })
                setTimeout(function () {
                window.location.reload();

                },1500)

            }
        });
    }

        var userId=user.id;
        $(function () {
            $.get(baseUrl+"/signIns/"+user.id,function (data) {
                //进入网页立即查询用户剩余积分
                $("#jifen").html("剩余积分:"+data.integral);
                if(data.integral>99){
                    $("#luckPointer").click(function () {
                    startRotate(this);

                    });

                }else {

                    $("#luckPointer").click(function () {

                        $(document).dialog({
                            titleText: '温馨提示',
                            content: "积分不足"

                        });

                    });
                }

            });
            //点击事件
            $("#lotto1").renderValues(user,{
                getHref:getHref
            });
        })

</script>
</body>

</html>